<?php

namespace App\Models\MainDB\WarOrder;

use Carbon\Carbon;
use Illuminate\Database\Eloquent\Model;

class WarOrderUser extends Model
{
    protected $table = 'ln_war_order_user';

    protected $fillable = [
        'id',
        'user_id',
        'war_order_id',//战令赛季id
        'level',//当前等级
        'experience',//当前经验值
        'add_time',
        'advanced',//1进阶战令0否
    ];

    public $timestamps = false;

    public function getWarOrderUser($user_id, $war_order_id)
    {
        $where = [
            'user_id'      => $user_id,
            'war_order_id' => $war_order_id,
        ];
        $data = [
            'user_id'      => $user_id,
            'war_order_id' => $war_order_id,
            'level'        => 0,
            'experience'   => 0,
            'add_time'     => Carbon::now()->timestamp,
            'advanced'     => 0,
        ];
        return $this->firstOrCreate($where, $data);
    }

}
